package com.ruoyi.project.modules.pageImageElementDetail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.modules.pageImageElementDetail.domain.PageImageElementConditionDetail;
import com.ruoyi.project.modules.pageImageElementDetail.service.IPageImageElementConditionDetailService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 页面图片与元素条件明细Controller
 * 
 * @author smallrain
 * @date 2022-05-06
 */
@Controller
@RequestMapping("/pageImageElementDetail/pageImageElementDetail")
public class PageImageElementConditionDetailController extends BaseController
{
    private String prefix = "pageImageElementDetail/pageImageElementDetail";

    @Autowired
    private IPageImageElementConditionDetailService pageImageElementConditionDetailService;

    @RequiresPermissions("pageImageElementDetail:pageImageElementDetail:view")
    @GetMapping()
    public String pageImageElementDetail()
    {
        return prefix + "/pageImageElementDetail";
    }

    /**
     * 查询页面图片与元素条件明细列表
     */
    @RequiresPermissions("pageImageElementDetail:pageImageElementDetail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PageImageElementConditionDetail pageImageElementConditionDetail)
    {
        startPage();
        List<PageImageElementConditionDetail> list = pageImageElementConditionDetailService.selectPageImageElementConditionDetailList(pageImageElementConditionDetail);
        return getDataTable(list);
    }

    /**
     * 导出页面图片与元素条件明细列表
     */
    @RequiresPermissions("pageImageElementDetail:pageImageElementDetail:export")
    @Log(title = "页面图片与元素条件明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PageImageElementConditionDetail pageImageElementConditionDetail)
    {
        List<PageImageElementConditionDetail> list = pageImageElementConditionDetailService.selectPageImageElementConditionDetailList(pageImageElementConditionDetail);
        ExcelUtil<PageImageElementConditionDetail> util = new ExcelUtil<PageImageElementConditionDetail>(PageImageElementConditionDetail.class);
        return util.exportExcel(list, "页面图片与元素条件明细数据");
    }

    /**
     * 新增页面图片与元素条件明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存页面图片与元素条件明细
     */
    @RequiresPermissions("pageImageElementDetail:pageImageElementDetail:add")
    @Log(title = "页面图片与元素条件明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PageImageElementConditionDetail pageImageElementConditionDetail)
    {
        return toAjax(pageImageElementConditionDetailService.insertPageImageElementConditionDetail(pageImageElementConditionDetail));
    }

    /**
     * 修改页面图片与元素条件明细
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PageImageElementConditionDetail pageImageElementConditionDetail = pageImageElementConditionDetailService.selectPageImageElementConditionDetailById(id);
        mmap.put("pageImageElementConditionDetail", pageImageElementConditionDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存页面图片与元素条件明细
     */
    @RequiresPermissions("pageImageElementDetail:pageImageElementDetail:edit")
    @Log(title = "页面图片与元素条件明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PageImageElementConditionDetail pageImageElementConditionDetail)
    {
        return toAjax(pageImageElementConditionDetailService.updatePageImageElementConditionDetail(pageImageElementConditionDetail));
    }

    /**
     * 删除页面图片与元素条件明细
     */
    @RequiresPermissions("pageImageElementDetail:pageImageElementDetail:remove")
    @Log(title = "页面图片与元素条件明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pageImageElementConditionDetailService.deletePageImageElementConditionDetailByIds(ids));
    }
}
